package com.example.httpdemo.mmkv;

public class LocalStorage {

    private static volatile LocalStorage instance;

    public static LocalStorage getInstance() {
        if (instance == null) {
            synchronized (LocalStorage.class) {
                if (instance == null) {
                    instance = new LocalStorage();
                }
            }
        }
        return instance;
    }

    /**
     * 保存用户登录token
     */
    public void setToken(String token) {
        MMKVHelper.put(StorageKeys.USER_TOKEN, token);
    }

    /**
     * 获取用户登录token
     */
    public String getToken() {
        return MMKVHelper.get(StorageKeys.USER_TOKEN, "");
    }

    public void setRefreshToken(String token) {
        MMKVHelper.put(StorageKeys.REFRESH_TOKEN, token);
    }

    public String getRefreshToken() {
        return MMKVHelper.get(StorageKeys.REFRESH_TOKEN, "");
    }

    /**
     * 是否同意隐私政策
     */
    public void setAgreePolicy(boolean isAgree) {
        MMKVHelper.put(StorageKeys.APP_POLICY, isAgree);
    }

    /**
     * 获取 是否同意隐私政策
     */
    public boolean isAgreePolicy() {
        return MMKVHelper.get(StorageKeys.APP_POLICY, false);
    }

    /**
     * 设置第一次进入应用
     */
    public void setFirstStart(boolean isAgree) {
        MMKVHelper.put(StorageKeys.APP_FIRST_START, isAgree);
    }

    /**
     * 是否是第一次进入应用
     */
    public boolean isFirstStart() {
        return MMKVHelper.get(StorageKeys.APP_FIRST_START, true);
    }

    /**
     * 设置
     */
    public void setVersionNum(int versionNum) {
        MMKVHelper.put(StorageKeys.APP_VERSION_NUM, versionNum);
    }

    /**
     * 获取用户登录token
     */
    public int getVersionNum() {
        return MMKVHelper.get(StorageKeys.APP_VERSION_NUM, -1);
    }


    /**
     * 设置取消更新弹窗
     */
    public void setCancelUpdate(boolean isCancelUpdate) {
        MMKVHelper.put(StorageKeys.APP_CANCEL_UPDATE, isCancelUpdate);
    }

    /**
     * 是否取消更新app弹窗
     */
    public boolean isCancelUpdate() {
        return MMKVHelper.get(StorageKeys.APP_CANCEL_UPDATE, false);
    }

    /**
     * 设置教师Id
     */
    public void setTeacherId(String teacherId) {
        MMKVHelper.put(StorageKeys.TEACHER_ID, teacherId);
    }

    /**
     * 获取教师Id
     */
    public String getTeacherId() {
        return MMKVHelper.get(StorageKeys.TEACHER_ID, "");
    }

    /**
     * 设置用户权限
     */
    public void setPermissionList(String permissionList) {
        MMKVHelper.put(StorageKeys.PERMISSION_LIST, permissionList);
    }

    /**
     * 获取用户权限
     */
    public String getPermissionList() {
        return MMKVHelper.get(StorageKeys.PERMISSION_LIST, "");
    }

    /**
     * 登录登录返回的当前带班学年的开始日期
     *
     * @param startTime
     */
    public void setYearStartTimeFromLogin(String startTime) {
        MMKVHelper.put(StorageKeys.YEAR_START_TIME_FROM_LOGIN, startTime);
    }

    public String getYearStartTimeFromLogin() {
        return MMKVHelper.get(StorageKeys.YEAR_START_TIME_FROM_LOGIN, "");
    }

    /**
     * 登录配置(后台切前台每天至少调一次loginConfig接口)
     * @param currDay
     */
    public void setLoginConfigRecordDate(String currDay) {
        MMKVHelper.put(StorageKeys.LOGIN_CONFIG_REQUEST_RECORD, currDay);
    }

    public String getLoginConfigRecordDate() {
        return MMKVHelper.get(StorageKeys.LOGIN_CONFIG_REQUEST_RECORD, "");
    }

    /**
     * 课程审批-相关审批单跳转到审批中心-切换到待审批
     * @param isHaveApproval
     */
    public void setIsHaveApproval(boolean isHaveApproval) {
        MMKVHelper.put(StorageKeys.Approval.SELECT_APPROVAL_TEACHER,isHaveApproval);
    }

    public boolean isHaveApproval() {
        return MMKVHelper.get(StorageKeys.Approval.SELECT_APPROVAL_TEACHER, false);
    }


    /**
     * 是否是内置管理员
     * @param schoolAdmin
     */
    public void setSchoolAdmin(boolean schoolAdmin) {
        MMKVHelper.put(StorageKeys.Approval.SCHOOL_ADMIN,schoolAdmin);
    }

    public boolean isSchoolAdmin() {
        return MMKVHelper.get(StorageKeys.Approval.SCHOOL_ADMIN, false);
    }

    /**
     * 设置周报跳转
     * @param weekPlanSkipInfo
     */
    public void setWeekPlanSkip(String weekPlanSkipInfo) {
        MMKVHelper.put(StorageKeys.WEEK_PLAN_SKIP,weekPlanSkipInfo);
    }

    public String getWeekPlanSkip() {
        return MMKVHelper.get(StorageKeys.WEEK_PLAN_SKIP, "");
    }
    /**
     * 设置周报跳转
     * @param isSkip
     */
    public void setIsWeekPlanSkip(boolean isSkip) {
        MMKVHelper.put(StorageKeys.IS_WEEK_PLAN_SKIP,isSkip);
    }

    public boolean isWeekPlanSkip() {
        return MMKVHelper.get(StorageKeys.IS_WEEK_PLAN_SKIP, false);
    }


    public void setFromWorkPlat(boolean fromWorkPlat) {
        MMKVHelper.put(StorageKeys.FROM_WORK_PLAT,fromWorkPlat);
    }
    public boolean isFromWorkPlat() {
        return MMKVHelper.get(StorageKeys.FROM_WORK_PLAT, false);
    }

    public String getGameRecordingApprovalPerson() {
        return MMKVHelper.get(StorageKeys.GAME_RECORDING_APPROVAL_PERSON, "");
    }
    public void setGameRecordingApprovalPerson(String approvalPerson) {
        MMKVHelper.put(StorageKeys.GAME_RECORDING_APPROVAL_PERSON,approvalPerson);
    }


}
